//
//  MovieViewController.m
//  A段项目
//
//  Created by ～whc on 15-6-18.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "MovieViewController.h"
#define ButtonHight 30
#define ButtonWidth 80
@interface MovieViewController ()

@end

@implementation MovieViewController

- (void)dealloc
{
    [self.hotMovie release];
    [self.comingMovie release];
    [self.hotButton release];
    [self.comingButton release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor blueColor]];
//    self.navigationController.navigationBar.translucent = NO;
    [[DateHandel shareHandle]openDB];
    
        
   
    [self createButton];
}

- (void)createButton
{
#warning 容器视图控制器
    self.comingMovie = [[ComingMovieViewController alloc] init];
    [self addChildViewController:self.comingMovie];
    [self.view addSubview:self.comingMovie.view];
    
    self.hotMovie = [[HotMovieViewController alloc] init];
    [self addChildViewController:self.hotMovie];
    [self.view addSubview:self.hotMovie.view];
    
#warning 切换视图控制器
    NSArray *array = [NSArray arrayWithObjects:@"热播", @"即将上映", nil];
    UISegmentedControl *segmentedC = [[UISegmentedControl alloc] initWithItems:array];
    segmentedC.frame = CGRectMake(self.view.frame.size.width / 5, 30, self.view.frame.size.width / 2, 30);
    segmentedC.selectedSegmentIndex = 0;
    segmentedC.tintColor = [UIColor whiteColor];
    self.navigationItem.titleView = segmentedC;
    [segmentedC addTarget:self action:@selector(segmentedControlAction:) forControlEvents:UIControlEventValueChanged];
    
#warning 导航栏左侧按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"我的" style:UIBarButtonItemStyleDone target:self action:@selector(leftBarButtonItemAction)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    
    [self.comingMovie release];
    [self.hotMovie release];
    [segmentedC release];
    
}

- (void)leftBarButtonItemAction
{
    [self.sideMenuViewController presentLeftMenuViewController];
}


#warning 容器视图控制器调换
- (void)segmentedControlAction:(UISegmentedControl *)Seg
{
    NSInteger index = Seg.selectedSegmentIndex;
    switch (index) {
        case 0:
            [self.view bringSubviewToFront:self.hotMovie.view];
            break;
        case 1:
            [self.view bringSubviewToFront:self.comingMovie.view];
            break;
            
        default:
            break;
    }
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
